package com.tj.test.sys.controller;

import com.tj.test.sys.po.Roler;
import com.tj.test.sys.service.impl.RolerService;
import com.tj.test.sys.tool.ResponseMessage;
import com.tj.test.sys.tool.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/roler")
@Controller
@Api(tags = "Roler")
@CrossOrigin
public class RolerController {
    @Autowired
    private RolerService service;

    @ApiOperation("查询角色全部信息")
    @RequestMapping(value = "/selectAll",method = RequestMethod.GET)
    @ResponseBody
    public ResponseMessage selectAllRoler(){
        List<Roler> list=service.selectAllRoler();
         if (!list.isEmpty()){
             return Result.success("查询成功",list);
         }
        return Result.error("查询信息失败");
    }

    @ApiOperation("根据id查询角色信息")
    @RequestMapping(value = "/selectById",method = RequestMethod.GET)
    @ResponseBody
    public ResponseMessage selectById(int rolerid){
        int temp=0;
        if (service.selectById(rolerid)!=null){
            return Result.success("查询成功",service.selectById(rolerid));
        }
        return Result.error("查询失败");
    }
}
